library(foreign)

dat <- read.dta("ceval.dta")

library(lme4)
library(effects)

mod2 <- lmer(formula = eval ~ dist * width +  copar + (1 | 
   caseid) + (1 + dist | cname), data = dat)


trellis.par.set(strip.background=list(col="white"))
eff2 <- effect("dist*width", mod2, typical="median", 
               xlevels = list(width=seq(min(dat$width), max(dat$width), length=5), 
               dist=seq(min(dat$dist, na.rm=T), max(dat$dist, na.rm=T), length=5)
               ))

pe2 <- plot(eff2,as.table=F, main="", 
            xlab="Ideological Distance", 
            ylab="Predicted Candidate Evaluation", rug=F, xvar="dist")

update(pe2, scales = list(cex = .75, y = list(at = c(-40, -20, 0, 20, 40),
            labels = c("-40", "-20", " 0", " 20", " 40")), 
            x=list(at=c(0,3,6), labels=c(0,3,6))), 
       layout = c(1,5), asp=.75)


library(LMERConvenienceFunctions)
pamer.fnc(mod2)

